package com.wlc.mapper;

import com.wlc.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户Mapper接口
 */
@Mapper
public interface UserMapper {

    Long selectUserCount(@Param("username") String username,
                         @Param("employeeName") String employeeName);

    List<User> selectUserList(@Param("username") String username,
                              @Param("employeeName") String employeeName,
                              @Param("offset") Integer offset,
                              @Param("limit") Integer limit);

    /**
     * 根据ID查询用户
     */
    User selectById(Long id);

    /**
     * 根据用户名查询用户
     */
    User selectByUsername(String username);

    /**
     * 查询用户列表
     */
    List<User> selectList(@Param("username") String username,
                          @Param("employeeName") String employeeName);

    /**
     * 新增用户
     */
    int insert(User user);

    /**
     * 更新用户
     */
    int update(User user);

    /**
     * 根据ID删除用户（物理删除）
     */
    int deleteById(Long id);

    /**
     * 根据ID启用/禁用用户
     */
    int updateStatus(@Param("id") Long id, @Param("isEnabled") Integer isEnabled);

    @Select("select id, username from sys_user where username = #{username} and password = #{password}")
    User selectByUsernameAndPassword(User user);
}